f=open('test.txt','w',encoding='utf-8')
f.close()
with open('test.txt','w+',encoding='utf-8') as f:
    f.write('这是第一行\n')
    list1=['这是第一行\n','这是第二行\n','这是第三行\n']
    f.writelines(list1)
    f.seek(0)
    print(f.read())
    f.seek(0)
    print('-----------------')
    # print(f.readline())
    while True:
        line = f.readline()
        if line:
            print(line,end=' ')
        else:
            break
    print('-----------------')
    f.seek(0)
    content = f.readlines()
    # print(content)
    for line in content:
        print(line,end=' ')